package org.example.design.strategy;

import org.example.design.strategy.impl.MJCouponDiscount;
import org.example.design.strategy.impl.NYGCouponDiscount;
import org.example.design.strategy.impl.ZJCouponDiscount;
import org.example.design.strategy.impl.ZKCouponDiscount;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * @Classname Test
 * @Description 策略模式、适配器模式、组合模式等，在一些结构上是比较相似的，
 * 但是每一个模式是有自己的逻辑特点，在使用的过程中最佳的方式是经过较多的实践来吸取经验，为后续的研发设计提供更好的技术输出。
 * @Date 2020/11/11 5:06 下午
 * @Created by xiangjd
 */
public class Test {
    private Logger logger = LoggerFactory.getLogger(Test.class);

    @org.junit.Test
    public void test1() {
        Context<Double> doubleContext = new Context<Double>(new ZKCouponDiscount());
        BigDecimal bigDecimal = doubleContext.disCount(0.8D, new BigDecimal(100));
        logger.info("测试结果：折扣优惠后金额 {}", bigDecimal);
    }

    @org.junit.Test
    public void test2() {
        Context<Double> doubleContext = new Context<Double>(new ZJCouponDiscount());
        BigDecimal bigDecimal = doubleContext.disCount(2D, new BigDecimal(100));
        logger.info("测试结果：直减优惠后金额 {}", bigDecimal);
    }

    @org.junit.Test
    public void test3() {
        Context<Double> doubleContext = new Context<Double>(new NYGCouponDiscount());
        BigDecimal bigDecimal = doubleContext.disCount(2D, new BigDecimal(100));
        logger.info("测试结果：N元购优惠后金额 {}", bigDecimal);
    }

    @org.junit.Test
    public void test4() {
        Context<Map<String, String>> doubleContext = new Context<Map<String, String>>(new MJCouponDiscount());
        Map<String, String> stringMap = new HashMap<String, String>();
        stringMap.put("x", "100");
        stringMap.put("n", "10");
        BigDecimal bigDecimal = doubleContext.disCount(stringMap, new BigDecimal(100));
        logger.info("测试结果：直减优惠后金额 {}", bigDecimal);
    }
}
